package com.kgc.controller;

import com.kgc.entity.Student;
import com.kgc.service.StudentService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 学生表(Student)表控制层
 *
 * @author unicorn
 * @since 2020-05-21 13:34:23
 */
@RestController
@RequestMapping("student")
public class StudentController {
    /**
     * 服务对象
     */
    @Resource
    private StudentService studentService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Student selectOne(@RequestParam("id") Integer id) {
        return this.studentService.queryById(id);
    }

    @PostMapping(value = "login")
    public String login(@RequestBody Student student){
        return this.studentService.login(student);
    }

    @PostMapping(value = "updateStudent")
    public Integer updateStudent(@RequestBody Student student){
        return this.studentService.update(student);
    }

    @GetMapping(value = "deleteStudent")
    public Integer deleteStudent(@RequestParam("id") Integer id){
        return this.studentService.deleteById(id);
    }

    @PostMapping(value = "insertStudent")
    public Integer insertStudent(@RequestBody Student student){
        return this.studentService.insert(student);
    }

}